package controller;

import java.util.List;

import com.opensymphony.xwork2.ActionContext;

import hibernate.Orderstab;
import hibernate.OrderstabDAO;


public class NewOrder {
	private List<Orderstab> orders;
	
	
	public List<Orderstab> getOrders() {
		return orders;
	}

    //未处理订单
	public List<Orderstab> untreatedOrders(int id) throws Exception {
		//ActionContext ctx = ActionContext.getContext();	
		//System.out.println(ctx.getSession().get("parkID"));
		OrderstabDAO orderstabDAO = new OrderstabDAO();
		orderstabDAO.getSession().beginTransaction();
		
		try{
			orders = orderstabDAO.queryOrder(id,0);
			orderstabDAO.getSession().getTransaction().commit();
		}catch(Exception e){
			e.printStackTrace();
		}
		finally{
			orderstabDAO.getSession().close();
		}
		return orders;
	}
	
	//已处理订单
	public List<Orderstab> treatedOrders(int id) throws Exception {
		//ActionContext ctx = ActionContext.getContext();	
		//System.out.println(ctx.getSession().get("parkID"));
		OrderstabDAO orderstabDAO = new OrderstabDAO();
		orderstabDAO.getSession().beginTransaction();
		
		try{
			orders = orderstabDAO.queryOrder(id,1);
			orderstabDAO.getSession().getTransaction().commit();
		}catch(Exception e){
			e.printStackTrace();
		}
		finally{
			orderstabDAO.getSession().close();
		}
		return orders;
	}

}
